package properties;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author oldliu
 * @since 1.0
 */
public class Demo {
    public static void main(String[] args) {
        Properties p = new Properties();
        try {
            // p.load(new FileInputStream("E:\\java_workspace\\IdeaProjects\\java81\\java高级\\src\\serverconfig
            // .properties"));
            InputStream in = Demo.class.getClassLoader().getResourceAsStream("serverconfig.properties");
            p.load(in);
            System.out.println(p);
            System.out.println("ip地址是：" + p.getProperty("ip", "127.0.0.2"));
            System.out.println("端口是:" + Integer.parseInt(p.getProperty("port")));

            // p.store();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
